<?php
/**
 * 小程序接口服务层
 * @author maniac
 */
namespace app\common\service;

use app\facade\Aes AS AesFacade;

class Routine extends Base
{
    /**
     * code2Session 换取用户唯一标识 OpenID 和 会话密钥 session_key
     * @param string $code 用户登录凭证
     */
    public function code2Session($code)
    {
        $uri = 'https://api.weixin.qq.com/sns/jscode2session?appid='.config('site.app_id').'&secret='.config('site.app_secret').'&js_code='.$code.'&grant_type=authorization_code';
        $result = json_decode(curl_request($uri));
        return $result->openid;
    }
}